<?php

namespace app\api\controller;

use app\common\controller\Api;
use fast\Http;
use think\Db;

use app\api\model\Joinpay;
use app\api\model\Leshuapay;
use app\api\model\Order;
use think\Exception;
use think\Request;

/**
 * 示例接口
 */
class Querys extends Api
{

    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
    //如果接口已经设置无需登录,那也就无需鉴权了
    //
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['index', 'test','getOrderStatus'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['test2'];

    // 在构造函数中应用中间件
    protected $middleware = [
        \app\api\middleware\AuthMiddleware::class
    ];


    public function getOrderStatus()
    {
        $orderPostId = $this->request->param('orderpostid');

        $data = ['status' => 0,'paystatus' => 0];

        if ($orderPostId){
            $orderPost = Db('orderPost')->where(['id' => $orderPostId])->find();
            $order = Db('orderLists')->where(['ordersn' => $orderPost['ordersn']])->find();
            if ($order){
                $data = ['statustext' => $order['status'],'status' => $order['paystatus']];
            }
        }



        $this->success('',$data);
    }

}
